package cn.pconline.autoclub.entity;

import java.util.Date;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Transient;

import cn.pconline.autoclub.util.AppUtils;

@Entity(tableName = "ac_club_album")
public class Album {

    public final static int ISDEFAULT_YES = 0;  // 是否默认相册--是
    public final static int ISDEFAULT_NO = 1; // 是否默认相册--否
    public final static int STATUS_NORMAL = 1;  // 正常状态
    public final static int STATUS_DELETE = -1; // 已删除状态
    @Id
    @Column(name = "album_id")
    private long albumId; // ID
    @Column(name = "club_id")
    private long clubId; // 车友会ID
    @Column(name = "name")
    private String name; // 名称
    @Column(name = "cover")
    private String cover; // 封面URL
    @Column(name = "quantity")
    private int quantity = 0; // 图片数量
    @Column(name = "create_by")
    private long createBy; // 创建者
    @Column(name = "create_at")
    private Date createAt; // 创建时间
    @Column(name = "update_at")
    private Date updateAt; // 更新时间
    @Column(name = "is_default")
    private int isDefault = ISDEFAULT_NO; // 状态
    @Column(name = "status")
    private int status = STATUS_NORMAL; // 状态
    @Transient
    public String cover160x120;
    @Transient
    public String cover294x294;
    @Transient
    private List<Photo> photos;

    public List<Photo> getPhotos() {
        return this.photos;
    }

    public void setPhotos(List<Photo> photos) {
        this.photos = photos;
    }

    public String getCover160x120() {
        return AppUtils.converImg(cover,"_1024x1024", "_160x120");
    }

    public String getCover294x294() {
        return  AppUtils.converImg(cover,"_1024x1024", "_294x294");
    }

    public String getCover144x144() {
        return AppUtils.converImg(cover,"_1024x1024", "_144x144");
    }

    public String getCover400x400() {
        return AppUtils.converImg(cover,"_1024x1024", "_400x400");
    }

    public long getAlbumId() {
        return albumId;
    }

    public void setAlbumId(long albumId) {
        this.albumId = albumId;
    }

    public long getClubId() {
        return clubId;
    }

    public void setClubId(long clubId) {
        this.clubId = clubId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public long getCreateBy() {
        return createBy;
    }

    public void setCreateBy(long createBy) {
        this.createBy = createBy;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public Date getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Date updateAt) {
        this.updateAt = updateAt;
    }

    public int getIsDefault() {
        return isDefault;
    }

    public void setIsDefault(int isDefault) {
        this.isDefault = isDefault;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @Override
    public int hashCode() {
        return String.valueOf(this.albumId).hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof Album)) {
            return false;
        }
        Album album = (Album) obj;
        if (album.getAlbumId() == this.albumId) {
            return true;
        }
        return false;
    }
}
